<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="学校编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenantId">
              <a-input v-model="model.tenantId" placeholder="请输入学校编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="gradeId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gradeId">
              <a-input v-model="model.gradeId" placeholder="请输入gradeId"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="年级编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gradeCode">
              <a-input v-model="model.gradeCode" placeholder="请输入年级编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="年级名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gradeName">
              <a-input v-model="model.gradeName" placeholder="请输入年级名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="主键ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classId">
              <a-input v-model="model.classId" placeholder="请输入主键ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="班级编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classCode">
              <a-input v-model="model.classCode" placeholder="请输入班级编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="班级名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="className">
              <a-input v-model="model.className" placeholder="请输入班级名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="班级简称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classNickname">
              <a-input v-model="model.classNickname" placeholder="请输入班级简称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="主键ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="studentId">
              <a-input v-model="model.studentId" placeholder="请输入主键ID"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="学生学号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="studentNo">
              <a-input v-model="model.studentNo" placeholder="请输入学生学号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="学生姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="studentName">
              <a-input v-model="model.studentName" placeholder="请输入学生姓名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="exaPapProItemId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="exaPapProItemId">
              <a-input-number v-model="model.exaPapProItemId" placeholder="请输入exaPapProItemId" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="exaPapProItemCode" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="exaPapProItemCode">
              <a-input v-model="model.exaPapProItemCode" placeholder="请输入exaPapProItemCode"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="exaPapProItemName" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="exaPapProItemName">
              <a-input v-model="model.exaPapProItemName" placeholder="请输入exaPapProItemName"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="subjectId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectId">
              <a-input v-model="model.subjectId" placeholder="请输入subjectId"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="subjectNames" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectNames">
              <a-textarea v-model="model.subjectNames" rows="4" placeholder="请输入subjectNames" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="teacherId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teacherId">
              <a-input v-model="model.teacherId" placeholder="请输入teacherId"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="teacherName" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teacherName">
              <a-input v-model="model.teacherName" placeholder="请输入teacherName"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="examinationPaperId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="examinationPaperId">
              <a-input v-model="model.examinationPaperId" placeholder="请输入examinationPaperId"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="examinationPaperNames" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="examinationPaperNames">
              <a-textarea v-model="model.examinationPaperNames" rows="4" placeholder="请输入examinationPaperNames" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属考试id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="examinationId">
              <a-input v-model="model.examinationId" placeholder="请输入所属考试id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="考试编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="examinationCode">
              <a-input v-model="model.examinationCode" placeholder="请输入考试编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="考试名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="examinationName">
              <a-input v-model="model.examinationName" placeholder="请输入考试名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="排序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gradeOrder">
              <a-input-number v-model="model.gradeOrder" placeholder="请输入排序" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="班级排序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classOrder">
              <a-input-number v-model="model.classOrder" placeholder="请输入班级排序" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="subjectOrder" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subjectOrder">
              <a-input-number v-model="model.subjectOrder" placeholder="请输入subjectOrder" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="学生显示顺序" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="studentOrder">
              <a-input-number v-model="model.studentOrder" placeholder="请输入学生显示顺序" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="teacherOrder" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teacherOrder">
              <a-input-number v-model="model.teacherOrder" placeholder="请输入teacherOrder" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="examinationFullMarks" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="examinationFullMarks">
              <a-input-number v-model="model.examinationFullMarks" placeholder="请输入examinationFullMarks" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="examinationAchievementScore" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="examinationAchievementScore">
              <a-input-number v-model="model.examinationAchievementScore" placeholder="请输入examinationAchievementScore" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="成绩状态：1正常(默认) 2缺考 3作弊 4取消" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStatus">
              <a-input v-model="model.achievementStatus" placeholder="请输入成绩状态：1正常(默认) 2缺考 3作弊 4取消"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="achievementStatusName" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStatusName">
              <a-input v-model="model.achievementStatusName" placeholder="请输入achievementStatusName"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="考试日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementScoreTime">
              <j-date placeholder="请选择考试日期" v-model="model.achievementScoreTime"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="achievementScoreRank" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementScoreRank">
              <a-input-number v-model="model.achievementScoreRank" placeholder="请输入achievementScoreRank" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="achievementStandardId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStandardId">
              <a-input v-model="model.achievementStandardId" placeholder="请输入achievementStandardId"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStandardCode">
              <a-input v-model="model.achievementStandardCode" placeholder="请输入标准编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStandardName">
              <a-input v-model="model.achievementStandardName" placeholder="请输入标准名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准类型（1国标 2省标 3市区标 4县乡标 5本校标 6自定义标）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStandardTtype">
              <a-input-number v-model="model.achievementStandardTtype" placeholder="请输入标准类型（1国标 2省标 3市区标 4县乡标 5本校标 6自定义标）" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准用途：11试卷模板 12实际应用于试卷 21个人模板 22应用于个人 31班级模板 32应用于班级 41年级模板 42应用于年级 51学校级模板 52应用于学校 92考试总分标准 93考试总分计分规则" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStandardPurpose">
              <a-input v-model="model.achievementStandardPurpose" placeholder="请输入标准用途：11试卷模板 12实际应用于试卷 21个人模板 22应用于个人 31班级模板 32应用于班级 41年级模板 42应用于年级 51学校级模板 52应用于学校 92考试总分标准 93考试总分计分规则"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准序号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achievementStandardOrder">
              <a-input-number v-model="model.achievementStandardOrder" placeholder="请输入标准序号" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="achieveStandardItemId" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="achieveStandardItemId">
              <a-input v-model="model.achieveStandardItemId" placeholder="请输入achieveStandardItemId"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准分项编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standItemCode">
              <a-input v-model="model.standItemCode" placeholder="请输入标准分项编码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准分项目名称(不及格、及格、良好、优秀等）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standItemName">
              <a-input v-model="model.standItemName" placeholder="请输入标准分项目名称(不及格、及格、良好、优秀等）"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标准分项目别名简称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standItemAliasname">
              <a-input v-model="model.standItemAliasname" placeholder="请输入标准分项目别名简称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="分数最低分(含)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standItemLowestScore">
              <a-input-number v-model="model.standItemLowestScore" placeholder="请输入分数最低分(含)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="分数最高分(不含)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standItemHighestScore">
              <a-input-number v-model="model.standItemHighestScore" placeholder="请输入分数最高分(不含)" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="diffScore" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="diffScore">
              <a-input-number v-model="model.diffScore" placeholder="请输入diffScore" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="scoreSegmentIndex" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="scoreSegmentIndex">
              <a-input-number v-model="model.scoreSegmentIndex" placeholder="请输入scoreSegmentIndex" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="classAchiScoreRank" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classAchiScoreRank">
              <a-input-number v-model="model.classAchiScoreRank" placeholder="请输入classAchiScoreRank" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="gradeAchiScoreRank" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gradeAchiScoreRank">
              <a-input-number v-model="model.gradeAchiScoreRank" placeholder="请输入gradeAchiScoreRank" style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'AchStudentExaminationScoreForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           tenantId: [
              { required: true, message: '请输入学校编码!'},
           ],
           studentId: [
              { required: true, message: '请输入主键ID!'},
           ],
           studentName: [
              { required: true, message: '请输入学生姓名!'},
           ],
           exaPapProItemId: [
              { required: true, message: '请输入exaPapProItemId!'},
           ],
           exaPapProItemCode: [
              { required: true, message: '请输入exaPapProItemCode!'},
           ],
           subjectId: [
              { required: true, message: '请输入subjectId!'},
           ],
           teacherId: [
              { required: true, message: '请输入teacherId!'},
           ],
           examinationPaperId: [
              { required: true, message: '请输入examinationPaperId!'},
           ],
           subjectOrder: [
              { required: true, message: '请输入subjectOrder!'},
           ],
           teacherOrder: [
              { required: true, message: '请输入teacherOrder!'},
           ],
           achievementScoreRank: [
              { required: true, message: '请输入achievementScoreRank!'},
           ],
           scoreSegmentIndex: [
              { required: true, message: '请输入scoreSegmentIndex!'},
           ],
           classAchiScoreRank: [
              { required: true, message: '请输入classAchiScoreRank!'},
           ],
           gradeAchiScoreRank: [
              { required: true, message: '请输入gradeAchiScoreRank!'},
           ],
        },
        url: {
          add: "/achstudent/achStudentExaminationScore/add",
          edit: "/achstudent/achStudentExaminationScore/edit",
          queryById: "/achstudent/achStudentExaminationScore/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>